#define _CRT_SECURE_NO_WARNINGS 1

#include<iostream>
#include<vector>
using namespace std;
//旋转数组的最小数字
//解法一 遍历数组
class Solution {
public:
    int minArray(vector<int>& numbers) {
        for (int i = 1;i < numbers.size();i++)
        {
            if (numbers[i] < numbers[i - 1])
                return numbers[i];
        }
        return numbers[0];
    }
};
//解法二 二分法

class Solution {
public:
    int minArray(vector<int>& numbers) {
        int i = 0, j = numbers.size() - 1;
        while (i < j)
        {
            int m = (i + j) / 2;
            if (numbers[m] > numbers[j])
            {
                i = m + 1;
            }
            else if (numbers[m] < numbers[j])
            {
                j = m;
            }
            else j--;
        }
        return numbers[i];
    }
};



